#!/usr/bin/perl
#use utf8;
use LWP::Simple;

my $url = 'http://www.mitbbs.com/bbsdoc2/Pics_3.html';
my $content = get $url;
die "Couldn't get $url" unless defined $content;

@all_lines = split("\n", $content);

#$downloads = ();

for($i=0; $i < @all_lines; $i++)
{
	if($all_lines[$i] =~ /@/)
	{
		$all_lines[$i+4] =~ /<a[^>]*>([^<]+)<.*/;
		$user = $1;
		mkdir $user unless -d $user;
		print $user;

		$all_lines[$i+1] =~ /<a href="([^"]+)".*/;
		$article = $1;
		$this_url = "http://www.mitbbs.com".$article;
		$this_content = get $this_url;
		@inner_lines = split("\n", $this_content);
#		foreach $inner_line (@inner_lines)
		$this_content =~ /article2\/([^\/]+)\/([^\/"]+)"/g;
		print "/article2/$1/$2";
#		print $this_content;
		print "\n";
	}
}
